﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="Unit.aspx.vb" Inherits="bisaska.Unit" %>
<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<form id="form1" runat="server" >
<asp:ScriptManager ID="DivisiScriptManager" runat="server" EnablePartialRendering="true" EnablePageMethods="true"/>
<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" 
              runat="server" 
              AllowPaging="True"
              AllowSorting="True" 
              AutoGenerateColumns="False" 
              DataKeyNames="id_unit"
              DataSourceID="T_MST_UNIT_Source" 
              CellPadding="4" 
              GridLines="None" 
              AlternatingRowStyle-CssClass="odd"
              CssClass="table-data">
  <Columns>
    <asp:BoundField DataField="id_unit" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="id_unit" />
    <asp:BoundField DataField="kode_unit" HeaderText="Kode Unit" SortExpression="kode_unit" />
    <asp:BoundField DataField="deskripsi" HeaderText="Deskripsi" SortExpression="deskripsi" />
    <asp:BoundField DataField="kode_divisi" HeaderText="Kode Divisi" SortExpression="kode_divisi" />
    <asp:BoundField DataField="is_active" HeaderText="Status" SortExpression="is_active" />
    <asp:BoundField DataField="tgl_update" HeaderText="Tanggal Update" SortExpression="tgl_update" />
    <asp:CommandField SelectText="Edit" ShowSelectButton="True" />
    <asp:TemplateField>
      <ItemTemplate>
        <asp:LinkButton ID="deleteButton" runat="server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Delete data ?');" />
      </ItemTemplate>
    </asp:TemplateField>
    <asp:ButtonField CommandName="btnCopy" Text="Copy" />
  </Columns>
</asp:GridView>
<div class="paging">
  <em><asp:Button ID="Button3" runat="server" Text="Add New" CausesValidation="False" CssClass="button" /></em><div style="clear:both;"></div>
</div>       
<table runat="server" id="tabel1" cellpadding="0" cellspacing="2" border="0" class="table-form">
  <tr>
    <th>Kode Unit</th>
    <td>
      <asp:TextBox ID="textbox1" runat="server" CssClass="textbox" MaxLength="12"></asp:TextBox>
      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="textbox1" ErrorMessage="*" ></asp:RequiredFieldValidator>
    </td>
  </tr>
  <tr>
    <th>Divisi</th>
    <td>
      <asp:DropDownList ID="dropdownlist1" runat="server" 
                            DataSourceID="T_MST_Divisi_Source" DataTextField="kode_divisi" 
                            DataValueField="kode_divisi">
      </asp:DropDownList>
    </td>
  </tr>
  <tr>
    <th valign="top">Deskripsi</th>
    <td>
      <asp:TextBox ID="textbox2" runat="server" TextMode="MultiLine" MaxLength="150"></asp:TextBox>
      <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="textbox2" ErrorMessage="*"></asp:RequiredFieldValidator>
    </td>
  </tr>
  <tr>
    <th>Status</th>
    <td>
      <asp:DropDownList ID="dropdownlist2" runat="server">
        <asp:ListItem Value="0">Aktif</asp:ListItem>
        <asp:ListItem Value="1">Pasif</asp:ListItem>
      </asp:DropDownList>
    </td>
  </tr>
  <tr>
    <td></td>
    <td>
      <asp:Button ID="button1" runat="server" Text="Save" CssClass="button"></asp:Button>
      <asp:Button ID="button2" runat="server" Text="Cancel" CssClass="button" CausesValidation="False"></asp:Button>
    </td>
  </tr>
</table>
<asp:SqlDataSource 
    ID="T_MST_UNIT_Source" 
    runat="server" 
    ConnectionString="<%$ ConnectionStrings:bisaska %>" 
    SelectCommand="select id_unit,kode_unit,a.deskripsi,b.kode_divisi,is_active = case a.is_active when 0 then 'Aktif' else 'Pasif' end,a.tgl_update  from T_MST_UNIT a join T_MST_DIVISI b on a.id_divisi = b.id_divisi"
    DeleteCommand="DELETE FROM [T_MST_UNIT] WHERE [id_unit] = @id_unit">
    <DeleteParameters>
      <asp:Parameter Name="id_unit" Type="Int64" />
    </DeleteParameters>
</asp:SqlDataSource>
<asp:SqlDataSource 
    ID="T_MST_Divisi_Source" 
    runat="server" 
    ConnectionString="<%$ ConnectionStrings:bisaska %>" 
    SelectCommand="SELECT [id_divisi], [kode_divisi] FROM [T_MST_DIVISI]">
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel> 
</form>
</asp:Content>
